﻿using System.Collections.Generic;

namespace Yoozoo.Gameplay.RTS
{
    public class HudLodScaleConfig
    {
        public static Dictionary<LodHudType,HudLodScaleRule[]> HudScaleConfig = new Dictionary<LodHudType, HudLodScaleRule[]>();

        private const float ScaleFactorForLod1_2=1.88f;// 从LOD1的0%缩放到LOD2的100%并保持大小的缩放系数
        
        private const float ScaleFactorForLod3_5=24.0f;//   15.0f ;// 从LOD3的0%缩放到LOD5的100%并保持大小的缩放系数  

        private const float ScaleFactorForLod3_3=   1.0f+  (ScaleFactorForLod3_5 -1.0f)*8.0f/568.0f; //  0.193f/0.136f;// 从LOD3的0%缩放到LOD3的100%并保持大小的缩放系数
        private const float ScaleFactorForLod3_4=   1.0f+ (ScaleFactorForLod3_5 -1.0f)*108.0f/568.0f; //  0.9f/0.136f;// 从LOD3的0%缩放到LOD4的100%并保持大小的缩放系数

 //(GlobalConfig.ScaleFactor_Lod3_5 -1)*8/568 
        public void Dispose()
        {
            HudScaleConfig.Clear();
        }
        
        public void Init()
        {
            HudScaleConfig.Add(LodHudType.LodLowArmyInfo,new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.0065f,//0.0065f*1.17f,//0.0065f
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale = 0.008f,// 0.0065f*1.17f*ScaleFactorForLod1_2// 0.01139f
                }, 
                new HudLodScaleRule()
                {
                    StartScale = 0.009f,//*1.17f,
                    StartLod =3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale =  0.009f//  0.009f*1.17f*ScaleFactorForLod3_3 //  0.009f
                },
            });

            HudScaleConfig.Add(LodHudType.LodHighMarchHud, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.01f,
                    StartLod = 3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale =0.015f,
                },
                new HudLodScaleRule()
                {
                    StartScale =0.015f,
                    StartLod = 4,
                    StartPercent = 0,
                    EndLod = 4,
                    EndPercent = 100,
                    EndScale = 0.04f,
                },
                new HudLodScaleRule()
                {
                    StartScale = 0.04f,
                    StartLod = 5,
                    StartPercent = 0,
                    EndLod = 5,
                    EndPercent = 100,
                    EndScale =  0.2f,
                },
            });

            HudScaleConfig.Add(LodHudType.LodHighMarchHudPoint, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.01f,
                    StartLod = 3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale = 0.015f,
                },
                new HudLodScaleRule()
                {
                    StartScale = 0.015f,
                    StartLod = 4,
                    StartPercent = 0,
                    EndLod = 4,
                    EndPercent = 100,
                    EndScale = 0.07f,
                },
                new HudLodScaleRule()
                {
                    StartScale = 0.07f,
                    StartLod = 5,
                    StartPercent = 0,
                    EndLod = 5,
                    EndPercent = 100,
                    EndScale = 0.2f,
                },
            });
            HudScaleConfig.Add(LodHudType.MonsterLodLowHudMini, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale =1.135f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale =  1.4f,
                }
            });
            HudScaleConfig.Add(LodHudType.MonsterLodLowHudMiddle, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 1.135f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale = 1.4f
                }
                
            });
            HudScaleConfig.Add(LodHudType.MonsterLodLowHudMax, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.75f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale =  1.05f,
                }
            });
            HudScaleConfig.Add(LodHudType.MonsterLodHighHudMini, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.75f,
                    StartLod = 3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_3,
                },
                new HudLodScaleRule()
                {
                    StartScale =1.05f *ScaleFactorForLod3_3,
                    StartLod = 4,
                    StartPercent = 0,
                    EndLod = 4,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_3,
                },
                new HudLodScaleRule()
                {
                    StartScale = 1.05f *ScaleFactorForLod3_4,
                    StartLod = 5,
                    StartPercent = 0,
                    EndLod = 5,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_5,
                },
            });
            HudScaleConfig.Add(LodHudType.MonsterLodHighHudMiddle, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.75f,
                    StartLod = 3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_3,
                },
                new HudLodScaleRule()
                {
                    StartScale =1.05f *ScaleFactorForLod3_3,
                    StartLod = 4,
                    StartPercent = 0,
                    EndLod = 4,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_4,
                },
                new HudLodScaleRule()
                {
                    StartScale = 1.05f *ScaleFactorForLod3_4,
                    StartLod = 5,
                    StartPercent = 0,
                    EndLod = 5,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_5,
                },
            });
            HudScaleConfig.Add(LodHudType.MonsterLodHighHudMax, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.75f,
                    StartLod = 3,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_3,
                },
                new HudLodScaleRule()
                {
                    StartScale =1.05f *ScaleFactorForLod3_3,
                    StartLod = 4,
                    StartPercent = 0,
                    EndLod = 4,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_4,
                },
                new HudLodScaleRule()
                {
                    StartScale = 1.05f *ScaleFactorForLod3_4,
                    StartLod = 5,
                    StartPercent = 0,
                    EndLod = 5,
                    EndPercent = 100,
                    EndScale = 1.05f *ScaleFactorForLod3_5,
                },
            });

            HudScaleConfig.Add(LodHudType.MonsterRadarHud, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.005f*1.17f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale = 0.005f*1.17f * ScaleFactorForLod1_2// 0.01f
                },
            });
            
            HudScaleConfig.Add(LodHudType.PoliceHpBar, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.01f*1.17f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 0,
                    EndScale =  0.01f*1.17f * ScaleFactorForLod1_2//  0.02f
                },
            });
            HudScaleConfig.Add(LodHudType.WallHpBar, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.01f*1.17f,
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 3,
                    EndPercent = 0,
                    EndScale = 0.01f*1.17f * ScaleFactorForLod1_2//  0.02f
                },
            });

            HudScaleConfig.Add(LodHudType.CargoTruckHud, new HudLodScaleRule[]
            {
                new HudLodScaleRule()
                {
                    StartScale = 0.0065f,//0.0065f*1.17f,//0.0065f
                    StartLod = 1,
                    StartPercent = 0,
                    EndLod = 2,
                    EndPercent = 100,
                    EndScale = 0.008f,// 0.0065f*1.17f*ScaleFactorForLod1_2// 0.01139f
                },
            });
        }
    }


    public enum LodHudType
    {
        LodLowArmyInfo,//lod12部队头像
        LodHighMarchHud,//lod4头像
        LodHighMarchHudPoint,//部队的缩略图标
        // MonsterLod12Hud,//野怪的信息hud
        // MonsterLod3Hud,//野怪的图标,
        MonsterRadarHud,
        
        MonsterLodLowHudMini,//低层级 普通野怪
        MonsterLodLowHudMiddle,//低层级 精英野怪
        MonsterLodLowHudMax,//低层级 boss级别野怪
        
        MonsterLodHighHudMini,//高层级 普通野怪
        MonsterLodHighHudMiddle,//高层级 精英野怪
        MonsterLodHighHudMax,//高层级 boss级别野怪
        PoliceHpBar,
        WallHpBar,
        CargoTruckHud,
    }
    public class HudLodScaleRule
    {
        public float StartScale;  // 初始摄像机 缩放值
        public int StartLod;       //初始摄像机lod
        public float StartPercent;   // 初始摄像机percent
        public float EndScale;      // 结束摄像机 缩放值
        public int EndLod;         //结束摄像机lod
        public float EndPercent;   /// 结束摄像机percent
        public float MaxScale;
    }
}